//
//  ViewController.m
//  2015.11.5  w1
//
//  Created by blue on 15-11-5.
//  Copyright (c) 2015年 sxh. All rights reserved.
//

#import "ViewController.h"

#import "TestViewController.h"

#import "TableViewController.h"

@interface ViewController ()
{
    UILabel *l;
    
}
@end


@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    
    self.title=@"我的标题栏";
    
    self.view.backgroundColor = [UIColor greenColor];

    
    l = [UILabel new];
    l.text = @"你好！曾大屌丝";
    
    [l sizeToFit];
    l.center = CGPointMake(self.view.frame.size.width/2.0, self.view.frame.size.height/2.0);
    l.textColor = [UIColor blueColor];
    [self.view addSubview:l];
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    btn.frame = CGRectMake(100, 100, 200, 44);
    [btn setTitle:@"按钮" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    
    [btn addTarget:self action:@selector(onkuan:) forControlEvents:UIControlEventTouchUpInside];
    [btn addTarget:self action:@selector(onClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    
    
}

-(void)onkuan:(id)sender
{
    UIView *view=[[UIView alloc] initWithFrame:CGRectMake(20, 200, 200, 200)];
    view.layer.borderWidth=2;
    view.clipsToBounds=YES;
    [self.view addSubview:view];
    
}


-(void)onClick:(id)sender
{
    
//    UIView *line=[[UIView alloc] initWithFrame:CGRectMake(0, 200, 0, 6)];
//    line.backgroundColor = [UIColor purpleColor];
//    [self.view addSubview:line];
//    
//    
//    
//    UIView *line2 = [[UIView alloc] initWithFrame:CGRectMake(self.view.frame.size.width/2.0, 0, 6, 0)];
//    line2.backgroundColor = [UIColor purpleColor];
//    [self.view addSubview:line2];
//    
//    
//    
//    
//    [UIView animateWithDuration:0.6 animations:^{
//        line.frame = CGRectMake(0, 200, self.view.frame.size.width, 6);
//
//        } completion:^(BOOL finish) {
//            [UIView animateWithDuration:0.6 animations:^{
//                line.frame = CGRectMake(self.view.frame.size.width , 200, 0, 6);
//                line2.frame = CGRectMake(self.view.frame.size.width/2.0, 0, 6, self.view.frame.size.height);
//            }completion:^(BOOL finish) {
//                [UIView animateWithDuration:0.6 animations:^{
//                    line2.frame = CGRectMake(self.view.frame.size.width/2.0, self.view.frame.size.height, 6, 0);
//                }];
//
//            }];
//        }];
    

    
    TableViewController *con = [TableViewController new];
    [self.navigationController pushViewController:con animated:YES];
    
}





-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [UIView animateWithDuration:1.6 animations:^{l.center = CGPointMake(self.view.frame.size.width/5.9, self.view.frame.size.height - 44);}];
    
    
    
}




- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
